package slash.world;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import java.util.*;

import slash.entities.*;

public class EntityLayer extends MapLayer {
	
	private ArrayList<LivingEntity> entities;
	
	public EntityLayer(){
		super();
		entities = new ArrayList<LivingEntity>();
	}
	
	/**
	 * Adds an entity to layer
	 * @param entity to add
	 */
	public void addEntity(LivingEntity entity){
		entities.add(entity);
	}

	@Override
	public void render(Graphics g) {
		if(isEnabled()){
			for(LivingEntity entity : entities){
				entity.render(g);
			}
		}
	}

	@Override
	public void update(GameContainer container, int time) {
		if(isEnabled()){
			for(LivingEntity entity : entities){
				entity.update(container, time);
			}
		}
	}

	@Override
	public ArrayList<AbstractEntity> getObjects() {
		ArrayList<AbstractEntity> objects = new ArrayList<AbstractEntity>();
		for(int x=1;x<entities.size();x++){
			AbstractEntity object = entities.get(x);
			objects.add(object);
		}
		return objects;
	}
}